package com.jielihaofeng.nio.bytebuffer;

import java.nio.ByteBuffer;

import static com.jielihaofeng.nio.bytebuffer.ByteBufferUtil.debugAll;

/**
 * @description 测试 ByteBuffer 读写
 * @author Johnnie Wind
 * @date 2021/10/1 20:03
 */
public class TestByteBufferReadWrite {

    public static void main(String[] args) {
        ByteBuffer buffer = ByteBuffer.allocate(10);
        buffer.put((byte)0x61); // 'a'
        debugAll(buffer);
        buffer.put(new byte[]{0x62,0x63,0x64}); // b c d
        debugAll(buffer);
//        System.out.println(buffer.get());
        buffer.flip();
        System.out.println(buffer.get());
        debugAll(buffer);
        buffer.compact();
        debugAll(buffer);
        buffer.put(new byte[]{0x65,0x66}); // e f
        debugAll(buffer);

    }

}
